package com.fang.service.impl;

import com.fang.dao.UsAdmin0Dao;
import com.fang.entity.UsAdmin0;
import com.fang.service.UsAdmin0Service;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 后台用户表(UsAdmin0)表服务实现类
 *
 * @author makejava
 * @since 2022-11-11 16:45:05
 */
@Service("usAdmin0Service")
public class UsAdmin0ServiceImpl implements UsAdmin0Service {
    @Resource
    private UsAdmin0Dao usAdmin0Dao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public UsAdmin0 queryById(Long id) {
        return this.usAdmin0Dao.queryById(id);
    }


    /**
     * 新增数据
     *
     * @param usAdmin0 实例对象
     * @return 实例对象
     */
    @Override
    public UsAdmin0 insert(UsAdmin0 usAdmin0) {
        this.usAdmin0Dao.insert(usAdmin0);
        return usAdmin0;
    }

    /**
     * 修改数据
     *
     * @param usAdmin0 实例对象
     * @return 实例对象
     */
    @Override
    public UsAdmin0 update(UsAdmin0 usAdmin0) {
        this.usAdmin0Dao.update(usAdmin0);
        return this.queryById(usAdmin0.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.usAdmin0Dao.deleteById(id) > 0;
    }

    @Override
    public List<UsAdmin0> select() {
        return this.usAdmin0Dao.selectAll();
    }
}
